from pydantic import BaseModel


class ItemBase(BaseModel):
    id: int
    Description: str
    Model: str
    Index: str
    Provider: str
    Units: str
    Quantity: float
    section_title: str


class ItemList:
    def __init__(self, items: list[ItemBase]) -> None:
        self.items = items
        self.sections = self.__get_section_list(items)

    @staticmethod
    def __get_section_list(items: list[ItemBase]) -> list[str]:
        unique_section = set()
        for item in items:
            unique_section.add(item["section_title"])
        return list(unique_section)

    def __iter__(self):
        return iter(self.items)

    def get_number_of_section(self) -> int:
        return len(self.sections)


class Provider(BaseModel):
    name: str
    e_mail: str
    phone: str | None = None
    man: str | None = None
